import {Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn} from "typeorm";
import {ApiProperty} from "@nestjs/swagger";
import {IsOptional} from "class-validator";

@Entity('sys_discuss')
export class DiscussEntity {
    @PrimaryGeneratedColumn({ type: 'bigint' })
    id: number

    @Column({ type: 'longtext', name: 'content', comment: '评论/留言内容' })
    content: string

    @IsOptional()
    @Column({ type: 'varchar',length:200, name: 'comment',default:'', comment: '评论描述信息' })
    comment?: string

    @Column({ type: 'varchar',length:200, name: 'commenter',default:'', comment: '评论者' })
    commenter: string

    @Column({type: 'bigint', name: 'blog_id',comment: '文章id，如果是留言则id固定为-1'})
    blogId: number

    @CreateDateColumn({ type: 'timestamp', name: 'create_date', comment: '创建时间',
        precision: 0,default:()=>'CURRENT_TIMESTAMP(0)'})
    @ApiProperty({ description: '创建时间' })
    createDate: Date

    @UpdateDateColumn({ type: 'timestamp', name: 'update_date', comment: '更新时间',
        precision: 0,default:()=>'CURRENT_TIMESTAMP(0)',onUpdate:'CURRENT_TIMESTAMP'
    })
    @ApiProperty({ description: '更新时间' })
    updateDate: Date
}

